/*
 * Copyright 2013 Glassy Cinema.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hu.glassy.web.component.common;

import hu.glassy.web.component.behaviour.DisableComponentOnAjaxCall;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.model.IModel;

/**
 * Ajax link kiterjesztett funkciókkal.
 *
 * @author molnar.alexander@sonrisa.hu
 */
public abstract class CustomAjaxLink extends AjaxLink<String>
{

  private static final long serialVersionUID = 1L;

  /**
   * Konstruktor
   *
   * @param id
   */
  public CustomAjaxLink(final String id)
  {
    this(id, null);
    setOutputMarkupId(true);
  }

  /**
   * Konstruktor
   *
   * @param id
   * @param form
   */
  public CustomAjaxLink(final String id, final IModel<String> model)
  {
    super(id, model);
  }

  @Override
  protected void updateAjaxAttributes(final AjaxRequestAttributes attributes)
  {
    attributes.getAjaxCallListeners().add(new DisableComponentOnAjaxCall());
  }
}
